﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.db.CompanyBusinessArchiveManager,com.newcrm.businessarchives.*,com.newcrm.bean.*,com.newcrm.db.CustomerCategoryManager,com.newcrm.db.CustomerFieldManager,java.net.URLEncoder,java.util.List,java.util.Map,java.util.ArrayList,java.util.Date" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  CustomerInfo customerInfo = (CustomerInfo)request.getAttribute("customerInfo");
  List<Map<String, Object>> peoples = (List<Map<String, Object>>)request.getAttribute("peoples");
  StringBuffer customerIds = new StringBuffer();
  customerIds.append(customerInfo.id);
  int peoplesNum = 0;
  if (peoples != null) {
    peoplesNum = peoples.size();
    for (Map<String, Object> p:peoples) {
      customerIds.append(",").append(p.get("CustomerId"));
    }
  }
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> dealCategory = companyInfo.dealCategorys;
  List<Map<String, Object>> taskCategory = companyInfo.taskCategorys;
  List<Map<String, Object>> customerCategorys = companyInfo.customerCategorys;
  List<User> users = companyInfo.users;
  List<Map<String, Object>> noteDefaultWords = companyInfo.noteDefaultWords;
  List<Map<String, Object>> companyTags = companyInfo.tags;
  List<Group> allGroups = companyInfo.getAllGroups();

  List<Map<String, Object>> fields = (List<Map<String, Object>>) request.getAttribute("fields");
  //销售自定义字段
  List<Map<String, Object>> dealFields = (List<Map<String, Object>>) request.getAttribute("dealFields");

  String assignDate = customerInfo.assignDate;

  User permissionUser = null;
  if (customerInfo.visible == Const.VISIBLE_PERSON) {
    permissionUser = Util.getUser(users, customerInfo.permissionsId);
  }

  String permissionUserAvatar = null;
  String belongUserName = null;
  if (permissionUser != null) {
    permissionUserAvatar = permissionUser.imgPath;
    belongUserName = permissionUser.name;
  }
  Date syncTime = (Date)request.getAttribute("syncTime");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title><%=Util.HTMLEncode(customerInfo.name)%></title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="renderer" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/qikebao.ico" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/all.css?ver=<%=Const.VERSION%>">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/datepicker.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-datetimepicker.min.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-wysihtml5.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/uploadify.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/magnific-popup.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/jplayer.blue.monday.min.css">
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-ui.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.bootstrap-growl.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/daterangepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.magnific-popup.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.cookie.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.uploadify.v3.2.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/popbox.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerCompany.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailTag.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailNote.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailCallRecords.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailDeals.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailImportantDate.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetailSearchEngine.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/customerDetail.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/area.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/json2.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/common.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/rightTask.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/sendmail.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.jplayer.min.js?ver=<%=Const.VERSION%>"></script>
  <script>
    $(function() {
      $("#partiesMenu").addClass("selected");
      $("#reMark").focus();
      showCompanyCategoryName();
      loadPermissionsChangeInfo();
      loadNoteInfo();
      loadTasks();
<%if (peoplesNum > 0) {%>
      loadPeopleTags(customerIds);
      loadPeopleExtInfo(customerIds);
<%}
  if (customerInfo.visible == Const.VISIBLE_EVERYONE && !user.isAdmin) { %>
      //不能填写备注
      $(".inputarea").hide();

      //不能修改客户
      $("#modify_customer_link").hide();

      //不能添加销售机会
      $(".blank_slate_layout").hide();
      $("#deals_addLink").hide();

      //不能修改标签
      $("#showmodifytag-link").hide();

      //不能修改分类
      $("#change_categoryId").prop( "disabled", true );

      //不能添加重要日期
      $("#add_contact_date_link").hide();
      $(".edit_links").hide();

      //不能创建联系人
      $("#addLinkPerson").hide();
      $("#addLinkPerson2").hide();

      $.bootstrapGrowl("公海客户仅为可读状态，不能添加备注等，如果需要修改，请转移到名下处理。");
<%}%>
    });

    var isPerson = false;
    var customerCategorys = new Array();
    <%if (customerCategorys != null) {
        for (Map<String, Object> category:customerCategorys) {
          String color = (String) category.get("Color");
          if (color == null || color.trim().length() == 0) {
            color = "000000";
          }
        %>
    customerCategorys.push({id:"<%=category.get("CategoryId")%>",name:"<%=Util.UEncode((String)category.get("CategoryName"))%>", color:"<%=color%>"});
    <%  }
      } %>
    var allDealsCategory = new Array();
    <%if (dealCategory != null) {
        for (Map<String, Object> category:dealCategory) {
          String color = (String) category.get("Color");
          if (color == null || color.trim().length() == 0) {
            color = "000000";
          }
        %>
    allDealsCategory.push({id:"<%=category.get("DealCategoryId")%>",name:"<%=Util.UEncode((String)category.get("DealCategoryName"))%>", color:"<%=color%>"});
    <%  }
      } %>
    var allUsers = new Array();
    <%if (users != null) {
        for (User u:users) { %>
    allUsers.push({id:"<%=u.userId%>",name:"<%=Util.UEncode(u.name)%>",photo:"<%=u.imgPath%>"});
    <%  }
      } %>
    var customerId = '<%=customerInfo.id%>';
    var customerIds = '<%=customerIds%>';
    var subjectType = <%=Const.TYPE_COMPANY%>;
    var loginUserId = '<%=user.userId%>';
    var isAdmin = <%=user.isAdmin%>;

    var parentCustomerId = '<%=customerInfo.id%>';
    var noteType = '<%=Const.TYPE_COMPANY%>';
    var ext_Type_email = <%=Const.CUSTOMER_EXT_INFO_TYPE_EMAIL%>;
    var ext_Type_im = <%=Const.CUSTOMER_EXT_INFO_TYPE_IM%>;
    var categoryId = "<%=customerInfo.categoryId%>";
    var visible_person = "<%=Const.VISIBLE_PERSON%>";
    
    // 销售机会自定义字段
    var allCustomerDealFields = new Array();
    <%if (dealFields != null) {
        for (Map<String, Object> field:dealFields) {
        %>
    allCustomerDealFields.push({id:"<%=field.get("DealFieldId")%>",name:"<%=Util.UEncode((String)field.get("DealFieldName"))%>"});
    <%  }
     } %>
  </script>
</head>
<body class="customerdetail">
  <jsp:include page="topNavi.jsp" flush="true"/>
  <div class="main-page">
    <div class="title top20">
    <table>
    <tr>
      <td class="avatar"><img src="<%=request.getContextPath()%>/images/avatar_company.png"></td>
      <td class="relative">
        <div class="rightarea">
          <%if (customerInfo.hasModifyRight(user, users)) {%>
          <div class="operationIcons" id="modify_customer_link">
          <a href="<%=request.getContextPath()%>/company/<%=customerInfo.id%>/edit" title="修改公司信息" class="iconbutton"><i class="fa fa-pencil"></i></a>
          <% if (user.isCanDelete()) {%><a id="delete_customer_link" title="删除公司" class="iconbutton" href="#delete-popup"><i class="fa fa-trash-o"></i></a><%}%>
          </div>
          <%}%>
          <%if (permissionUserAvatar != null) {%>
          <div class="avatars">
            <img title="所属员工：<%=Util.HTMLEncode(belongUserName)%>" src="<%=request.getContextPath()%>/<%=permissionUserAvatar%>">
          <% if (customerInfo.shareUserIds != null && customerInfo.shareUserIds.length() > 0) {
              for (String shareUserId:customerInfo.shareUserIds.split(",")) {
                User shareU = Util.getUser(users, shareUserId);
                if (shareU == null) {
                  continue;
                } %>
                <img title="共享员工：<%=Util.HTMLEncode(shareU.name)%>" src="<%=request.getContextPath()%>/<%=shareU.imgPath%>">
          <%
              }}
              
              if (customerInfo.shareGroupIds != null && customerInfo.shareGroupIds.length() > 0) {
                for (String shareGroup:customerInfo.shareGroupIds.split(",")) {
                  Group shareG = Util.getGroup(allGroups, shareGroup);
                  if (shareG == null) { 
                    continue;
                  } %>
                <img title="共享部门：<%=Util.HTMLEncode(shareG.getName())%>" src="<%=request.getContextPath()%>/images/avatar_company.png"">
            <%  }
              } %>
          </div>
          <%}%>
        </div>
        <h1><span id="categoryName" title="客户分类" class="category"></span><%=Util.HTMLEncode(customerInfo.name)%> <a id="open_phone_link" href="#callphone-popup" class="noiconbutton green small">打电话</a> <a id="open_email_link" href="#emailEditor-popup" class="noiconbutton blue small">发邮件</a> </h1>
        <div class="tags" id="show_tags"><span>
          <%List<Tag> tags = customerInfo.tags;
          for (Tag tag : tags) {%><a class="tag" tagId="<%=tag.id%>" href="<%=request.getContextPath()%>/parties?tagId=<%=tag.id%>"><%=Util.HTMLEncode(tag.name)%></a><%}%>
          </span><a class="tag" id="showmodifytag-link" href="#"><i class="fa fa-pencil"></i> 修改标签</a>
        </div>
        <div class="edittags" id="edit_tags">
          <div>
        <% if ((companyTags != null) && (companyTags.size() > 0)) {
        for (Map<String, Object> tag:companyTags) { %>
            <span id="allTags_<%=tag.get("TagId")%>" class="checkbox-button" v="0" tagid="<%=tag.get("TagId")%>"><i class="fa fa-fw fa-square-o"></i> <%=Util.HTMLEncode((String)tag.get("TagName"))%></span>
          <%}}%>
          </div><div class="clearfix"></div>
          <div>
            <a id="modifytag-link" class="button green small" href="#"><i class="fa fa-check"></i> 确定</a>
            <a id="modifytag-cancel-link" class="button grey small" href="#"><i class="fa fa-times"></i> 取消</a>
          </div>
        </div>
      </td>
    </tr>
    </table>
    </div>
    <div class="body">
      <table>
        <tr>
          <td class="content">
            <div class="switches">
              <a href="#notes_and_emails" class="activated">备注</a>
              <a id="peopleTabHeader" href="#people">联系人<%if (peoplesNum > 0) {%>(<%=peoplesNum%>)<%}%></a>
              <a href="#callRecords">通话</a>
              <a href="#deals">销售机会</a>
              <a href="#dates">重要日期</a>
              <a href="#searchEngineResult">资讯</a>
              <!--<a id="businessArchivesTabHeader" href="#businessArchives">工商</a>-->
            </div>
            <div class="switchable">
              <div id="notes_and_emails">
                <div class="inputarea">
                  <textarea cols="40" data-focus-priority="1" id="reMark" rows="16" style="width:99%;height:60px"></textarea>
                  <div class="bottom">
                    <span>
                      <a title="添加文件" class="iconbutton" href="file"><i class="fa fa-paperclip"></i></a>
                      <a title="设置下次联系时间" class="iconbutton" href="date"><i class="fa fa-bell-o"></i></a>
                      <%if (peoplesNum > 0) {%><a title="联系对象" class="iconbutton" href="user"><i class="fa fa-user"></i></a><%}%>
                      <div class="desc file" id="desc_file">
                        <div class="icon"><div class="iconbg"></div></div>
                        <div><input type="file" id="file_upload" name="file_upload" /></div>
                      </div>
                      <div class="desc date" id="desc_date">
                        <div class="icon"><div class="iconbg"></div></div>
                        <div>设置下次联系时间：<div class="datetimepicker_container"><input type="text" id="nextcontact_date" class="datetimepickerinput"></div></div>
                      </div>
                      <%if (peoplesNum > 0) {%>
                      <div class="desc user" id="desc_user">
                        <div class="icon"><div class="iconbg"></div></div>
                        <div>
                          <p>请选择联系的联系人：</p>
                          <div style="padding-top:10px;">
                          <label><input id="noPeople" name="contactPeople" v="" checked type="radio" value="" /> 无</label>
                          <%for (Map<String, Object> people : peoples) {%>
                          <label><input name="contactPeople" v="<%=Util.HTMLEncode((String)people.get("Name"))%>" type="radio" value="<%=people.get("CustomerId")%>" /> <%=Util.HTMLEncode((String)people.get("Name"))%></label>
                          <%}%>
                          </div>
                        </div>
                      </div>
                      <%}%>
                    </span>
                    <span class="right">
                      <a href="#" id="addnote-link" class="noiconbutton green">添加备注</a><a href="#" id="notedropmenu-link" class="addonicon"><i class="fa fa-chevron-down"></i> </a>
                      <div class="menu">
                        <ul>
                        <% if ((noteDefaultWords != null) && (noteDefaultWords.size() > 0)) {
                              for (Map<String, Object> defaultword:noteDefaultWords) { %>
                                <li><a href="#" class="n"><%=Util.HTMLEncode((String)defaultword.get("DefaultWord"))%></a></li>
                          <%  }
                            }%>
                          <% if (user.isAdmin) {%>
                                <li><a class="topline" target="_blank" href="<%=request.getContextPath()%>/noteDefaultWord"><i class="fa fa-gear"></i> 设置常用回复</a></li>
                          <%}%>
                        </ul>
                      </div>
                    </span>
                  </div>
                </div>
                <div class="clearfix"></div>
                <div id="notes_loading" class="loading">
                  <div class="liner">
                    <h3>备注信息加载中...</h3>
                    <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
                  </div>
                </div>
                <div class="feed_time_line_container">
                  <div class="export_note"><a href="#" id="export_note_link"><i class="fa fa-fw fa-download"></i> 导出备注</a></div>
                  <div class="feed_time_line" id="noteslist"></div>
                </div>
              </div>
              <div id="people" style="display:none">
                <%if (peoplesNum <= 0) { %>
                <div class="blank_slate_layout">
                  <div class="graphic" style="background-image:url(<%=request.getContextPath()%>/images/blankslate_icon_parties.png);"></div>
                  <div class="content">
                    <h1>创建公司联系人</h1>
                    <p>
                    创建联系人，并保存与之相关的记录，比如邮件，电话，会议等。这样您会很容易的看到该客户的进展情况。以及谁在和该客户联系。
                    </p>
                    <div class="menu_container controls" id="addLinkPerson">
                      <a href="<%=request.getContextPath()%>/company/<%=customerInfo.id%>/people/new" class="button green"><i class="fa fa-user"></i> 添加第一个联系人</a>
                    </div>
                  </div>
                </div>
                <% } else {%>
                <div id="addLinkPerson2"><a href="<%=request.getContextPath()%>/company/<%=customerInfo.id%>/people/new" class="button green"><i class="fa fa-user"></i> 添加联系人</a></div>
                <div class="searchresult">
                  <table class="index">
                    <%
                      for (Map<String, Object> people : peoples) {
                        String imgPath = (String) people.get("ImgPath");
                        if ((imgPath == null) || (imgPath.length() == 0)) {
                          imgPath = Const.IMAGE_AVATAR_PERSON;
                        } else {
                          imgPath = Const.IMAGE_PEOPLE_AVATAR_PATH + "/" + imgPath;
                        }
                    %>
                    <tr>
                      <td class="avatar">
                        <a href="<%=request.getContextPath()%>/people/<%=people.get("CustomerId")%>"><img alt="<%=Util.HTMLEncode((String)people.get("Name"))%>" height="55" width="55" src="<%=request.getContextPath()%>/<%=imgPath%>" title="<%=Util.HTMLEncode((String)people.get("Name"))%>"></a>
                      </td>
                      <td class="party">
                        <h3><a href="<%=request.getContextPath()%>/people/<%=people.get("CustomerId")%>" class="name"><%=Util.HTMLEncode((String)people.get("Name"))%></a></h3>
                        <%
                          String title = (String)people.get("Title");
                          if (title != null && title.trim().length() > 0) {
                          %><div class="title"><%=Util.HTMLEncode(title)%></div><%}%>
                        <p class="tags" id="tags_<%=people.get("CustomerId")%>"></p>
                        <h6 id="customer_extInfo_<%=people.get("CustomerId")%>">
                          <div class="other"></div>
                          <div class="mobile"></div>
                          <div class='qq'></div>
                        </h6>
                      </td>
                    </tr>
                    <%}%>
                  </table>
                </div>
                <%}%>
              </div>
              <div id="callRecords" style="display:none">
                <div id="callRecords_loading" class="loading">
                  <div class="liner">
                    <h3>通话信息加载中...</h3>
                    <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
                  </div>
                </div>
                <%if (syncTime != null) {%>
                <div class="syncTips">#最近同步：<%=Util.date2Str(syncTime)%> （默认每晚凌晨 3 点同步）<a href="#" id="syncCallRecords"><i class="fa fa-refresh"></i> 立即同步</a></div>
                <%}%>
                <div class="feed_time_line" id="callRecordslist"></div>
              </div>
              <div id="deals" style="display:none">
                <div id="deals_loading" class="loading">
                  <div class="liner">
                    <h3>销售机会加载中...</h3>
                    <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
                  </div>
                </div>
                <div id="deals_none" class="blank_slate_layout_container" style="display:none">
                  <div class="blank_slate_layout">
                    <div class="graphic" style="background-image:url(<%=request.getContextPath()%>/images/blankslate_icon_deals.png);"></div>
                    <div class="content"><h1>记录您的每一个销售机会</h1>
                      <p>
                        时刻关注每个销售机会的状态（中止，成交或失败），同时记录每个销售机会相关的任务或事件，以及其关键信息，比如合同金额，状态，成交额。
                      </p>
                      <a href="<%=request.getContextPath()%>/company/<%=customerInfo.id%>/deals/new" class="button green"><i class="fa fa-rmb"></i> 添加第一个销售机会</a>
                    </div>
                  </div>
                </div>
                <div class="deals" id="deals_list" style="display:none">
                  <a href="<%=request.getContextPath()%>/company/<%=customerInfo.id%>/deals/new" id="deals_addLink" class="button green"><i class="fa fa-rmb"></i> 添加销售机会</a>
                  <table class="deals" id="confirm_deals" style="display:none;">
                    <tr>
                      <th colspan="4" class="confirm">
                        <h2>待审核的销售机会</h2>
                      </th>
                    </tr>
                  </table>
                  <table class="deals" id="pending_deals" style="display:none;">
                    <tr>
                      <th colspan="4" class="pending">
                        <h2>跟踪中的销售机会</h2>
                      </th>
                    </tr>
                  </table>
                  <table class="deals" id="won_deals" style="display:none;">
                    <tr>
                      <th colspan="4" class="won">
                        <h2>已经成功的销售机会<span> &mdash; <span id="totalNum"></span> 笔 合计 <span id="totalMoney"></span> 元</span></h2>
                      </th>
                    </tr>
                  </table>
                  <table class="deals" id="lost_deals" style="display:none;">
                    <tr>
                      <th colspan="4" class="lost">
                        <h2>失败的销售机会</h2>
                      </th>
                    </tr>
                  </table>
                </div>
              </div>
              <div id="dates" style="display:none">
                <div id="dates_loading" class="loading">
                  <div class="liner">
                    <h3>重要日期加载中...</h3>
                    <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
                  </div>
                </div>
                <div class="recordings">
                  <h4>为客户添加重要日期</h4>
                  <p>您设置了重要日期后，到期的当天在系统的右上角会提醒您。</p>
                  <a id="add_contact_date_link" href="#" class="button green"><i class="fa fa-calendar"></i> 添加重要日期</a>
                  <div class="inline_edit" id="add_contact_date_panel" style="display:none;">
                    <div class="inner">
                      <h4>添加一个日期提醒</h4>
                      <div style="padding-bottom:10px;">
                        <select id="contact_date_occasion">
                          <option value="生日">生日</option>
                          <option value="周年纪念">周年纪念</option>
                          <option value="第一次见面">第一次见面</option>
                          <option value="服务到期时间">服务到期时间</option>
                          <option value="">其他...</option>
                        </select>  <input type="text" id="contact_date_custom_description" value="" style="height:18px;width:450px;display:none;">
                      </div>
                      <div>
                        <select id="contact_date_month">
                          <option value="1">一月</option>
                          <option value="2">二月</option>
                          <option value="3">三月</option>
                          <option value="4">四月</option>
                          <option value="5">五月</option>
                          <option value="6">六月</option>
                          <option value="7">七月</option>
                          <option value="8">八月</option>
                          <option value="9">九月</option>
                          <option value="10">十月</option>
                          <option value="11">十一月</option>
                          <option value="12">十二月</option>
                        </select>
                        <select id="contact_date_day">
                          <% for (int i = 1; i < 32; i++) {%>
                          <option value="<%=i%>"><%=i%></option>
                          <%}%>
                        </select>
                        <select id="contact_date_year">
                          <option value="0">每年</option>
                          <% for (int i = 1950; i < 2021; i++) {%>
                          <option value="<%=i%>"><%=i%></option>
                          <%}%>
                        </select>
                      </div>
                      <p id="new_importantDate_button_panel">
                        <a id="add_imporantDate_link" class="button blue small" href="#"><i class="fa fa-check"></i> 创 建</a>
                        <a id="add_imporantDate_cancel_link" class="button grey small" href="#"><i class="fa fa-times"></i> 取消</a>
                      </p>
                     </div>
                  </div>
                </div>
                <div id="contact_dates"></div>
              </div>
              <div id="searchEngineResult" style="display:none">
                <div style="height:30px;"><a id="refreshSearchEngine_link" class="button grey small right" href="#"><i class="fa fa-refresh"></i> 刷新</a></div>
                <div id="searchEnginestream">
                  <div id="searchEngines" class="recordings"></div>
                  <div id="searchEngines_loading" class="loading">
                    <div class="liner">
                      <h3>相关资讯检索中...</h3>
                      <img alt="Dots-white" src="<%=request.getContextPath()%>/images/dots-white.gif" />
                    </div>
                  </div>
                </div>
              </div>

              <div id="businessArchives" style="display:none" class="switchableContainer">
              </div>
            </div>
          </td>
          <td class="rightdesc">
            <div class="container">
              <%  if (customerInfo.visible == Const.VISIBLE_EVERYONE) { %>
              <a href="#" class="button blue" id="addCustomerToMyList_link" type="<%=Const.TYPE_COMPANY%>" customerId="<%=customerInfo.id%>" permissionId="<%=user.userId%>" title="加为我的客户"><i class="fa fa-plus"></i>加为我的客户</a>
              <%  } %>
              <h1>任务</h1>
              <div class="tasklist overdue" id="overdueTasks">
                <h6> 已过期 </h6>
                <ul class="tasks"></ul>
              </div>
              <div class="tasklist" id="todayTasks">
                <h6> 今天 </h6>
                <ul class="tasks"></ul>
              </div>
              <div class="tasklist" id="tomorrowTasks">
                <h6> 明天 </h6>
                <ul class="tasks"></ul>
              </div>
              <div class="tasklist" id="thisWeekTasks">
                <h6> 本周 </h6>
                <ul class="tasks"></ul>
              </div>
              <div class="tasklist" id="nextWeekTasks">
                <h6> 下周 </h6>
                <ul class="tasks"></ul>
              </div>
              <div class="tasklist" id="laterTasks">
                <h6> 以后 </h6>
                <ul class="tasks"></ul>
              </div>
              <%if (assignDate != null && assignDate.length() > 0) {%>
              <h1>分配时间</h1>
              <div class="data_group"><%=assignDate%></div>
              <%}%>
              <%if (customerCategorys != null && customerInfo.hasModifyRight(user, users)) {%>
              <h1>客户分类</h1>
              <div class="data_group">
                <select id="change_categoryId" class="max-width">
                <option value="0">无</option>
              <%for (Map<String, Object> category:customerCategorys) { %>
                <option value="<%=category.get("CategoryId")%>"><%=Util.HTMLEncode(Util.showMaxLen((String)category.get("CategoryName"), 12))%></option>
              <%}%>
                </select>
              </div>
              <%}%>
              <div id="permissionsChange_div">
                <h1>客户所属变更历史</h1>
                <div id="permissionsChangeDetail"></div>
              </div>
<%if (peoplesNum > 0) {%>
              <h1>联系人信息</h1>
              <ul class="peoples_desc">
<%            for (Map<String, Object> people : peoples) {%>
                <li>
                  <div><b><a href="<%=request.getContextPath()%>/people/<%=people.get("CustomerId")%>" target="_blank"><%=Util.HTMLEncode((String)people.get("Name"))%></a></b> <span><%=Util.HTMLEncode((String)people.get("Title"))%></span></div>
                  <p id="customer_extInfo_right_<%=people.get("CustomerId")%>"></p>
                </li>
<%}%>
              </ul>
<%}%>
              <h1>公司信息</h1>
              <div class="ext data_group">
                <div class="label">创建时间</div>
                <div class="value item"><%=customerInfo.createDate%></div>
              </div>
              <div class="email_address data_group">
                <%
                  List<ExtInfo> extInfos = customerInfo.extInfos;
                  for (ExtInfo extInfo : extInfos) {
                    if (Const.CUSTOMER_EXT_INFO_TYPE_EMAIL == extInfo.type) { %>
                <div class="value">
                  <a href="mailto:<%=extInfo.info1%>" class="mailaddress"><%=extInfo.info1%></a>
                </div>
                 <%
                    }
                  }
                %>
              </div>
              <div class="phone_number data_group">
                <%
                  List<String> phones = new ArrayList<String>();
                  for (ExtInfo extInfo: extInfos) {
                    if (Const.CUSTOMER_EXT_INFO_TYPE_PHONE == extInfo.type) {
                      phones.add(extInfo.info1);
                    %>
                <div class="value">
                  <%=Util.HTMLEncode(extInfo.info1)%>
                 <%
                      if (extInfo.isMobile()) { %>
                      <a href="#" class="searchLocation-link" m="<%=Util.HTMLEncode(extInfo.info1)%>">归属地</a><span class="location label"></span>
                   <% } %>
                </div>
               <%   }
                  }
                %>
              </div>
              <div class="website data_group">
                <%
                  for (ExtInfo extInfo: extInfos) {
                    if (Const.CUSTOMER_EXT_INFO_TYPE_WEBSITE == extInfo.type) { %>
                <div class="value">
                  <a href="http://<%=extInfo.getInfo1()%>" target="_blank"><%=Util.HTMLEncode(extInfo.getInfo1())%></a>
                </div>
                 <%
                    }
                  }
                %>
              </div>
              <div class="data_group">
                <%
                  for (ExtInfo extInfo: extInfos) {
                    if (Const.CUSTOMER_EXT_INFO_TYPE_ADDRESS == extInfo.type) { %>
                <%String mapAddress = URLEncoder.encode(extInfo.info3 + extInfo.info4 + extInfo.info1, "UTF-8");%>
                <a href="http://api.map.baidu.com/staticimage?center=<%=mapAddress%>&markers=<%=mapAddress%>" class="map" style="background-image:url(http://api.map.baidu.com/staticimage?width=200&height=90&markers=<%=mapAddress%>&center=<%=mapAddress%>);" target="_blank"></a>
                <div class="value"><%=Util.HTMLEncode(extInfo.info1)%> <br /> <%=extInfo.info3%> <%=extInfo.info4%></div>  <br/>
                 <%
                    }
                  }
                %>
              </div>
              <div class="instant_messenger data_group">
                <%
                  String imType = null;
                  for (ExtInfo extInfo: extInfos) {
                    if (Const.CUSTOMER_EXT_INFO_TYPE_IM == extInfo.type) {
                      if ((extInfo.info3 != null) && (!extInfo.info3.equals(imType))) {
                        imType = extInfo.info3; %>
                  <div class="label"><%=imType%></div>
                      <%
                      }
                      %>
                <div class="value">
                  <% if (Const.IM_QQ.equals(imType)) {%>
                  <%=Util.HTMLEncode(extInfo.info1)%> <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<%=Util.HTMLEncode(extInfo.info1)%>&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:<%=Util.HTMLEncode(extInfo.info1)%>:41" alt="点击这里给我发消息" title="点击这里给我发消息"></a>
                  <% } else {%>
                  <%=Util.HTMLEncode(extInfo.info1)%>
                  <% }%>
                </div>
                 <%
                    }
                  }
                %>
              </div>
              <div class="data_group">
                <%
                  for (ExtInfo extInfo: extInfos) {
                    if (extInfo.type >= Const.CUSTOMER_FIELD_ID_START && extInfo.info1 != null && extInfo.info1.trim().length() > 0) { %>
                <div class="label"><%=Util.getFieldName(extInfo.type, fields)%></div>
                <div class="value item"><%=Util.HTMLEncode(extInfo.info1)%></div>
                 <%
                    }
                  }
                %>
              </div>
              <%if (customerInfo.note != null && customerInfo.note.length() > 0) {%>
              <div class="data_group">
                <div class="label">简介</div>
                <div class="value"><%=Util.HTMLEncode(customerInfo.note).replaceAll("(\r\n|\n)", "<br/>")%></div>
              </div>
              <%}%>
            </div>
          </td>
        </tr>
      </table>
    </div>

    <div id="deletenote-popup" class="white-popup mfp-hide">
      <div class="popup-title"><span class="title">删除备注信息</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
      <div class="popup-content">
        确认要删除该备注信息吗？
      </div>
      <div class="buttonbar">
        <div class="right">
          <a id="deletenote-link" class="button blue small" href="#"><i class="fa fa-check"></i> 确定</a>
          <a class="button grey small popup-close-button" href="#"><i class="fa fa-times"></i> 取消</a>
        </div>
        <div class="message"></div>
      </div>
    </div>

    <div id="searchEngine_template" class="recording" style="display:none">
      <div class="listview">
        <div class="title"></div>
        <div class="body"></div>
      </div>
    </div>

    <div class="contact_date_wrapper" id="contact_date_template" style="display:none">
      <div class="contact_date">
        <p>
          <span class="edit_links">
            <a href="#" title="修改重要日期" class="edit"><i class="fa fa-pencil"></i> &nbsp;</a>
            <a class="delete" title="删除重要日期" href="#"><i class="fa fa-trash-o"></i> &nbsp;</a>
          </span>
          <span class="content_date"></span>
          <span class="content_type"></span>
        </p>
        <div class="inline_edit" style="display:none;">
          <div class="inner">
            <h4>修改日期提醒</h4>
            <div style="padding-bottom:10px;">
              <select class="occasion">
                <option value="生日">生日</option>
                <option value="周年纪念">周年纪念</option>
                <option value="第一次见面">第一次见面</option>
                <option value="服务到期时间">服务到期时间</option>
                <option value="">其他...</option>
              </select>  <input type="text" class="description" value="" style="height:18px;width:450px;display:none;">
            </div>
            <div>
              <select class="month">
                <option value="1">一月</option>
                <option value="2">二月</option>
                <option value="3">三月</option>
                <option value="4">四月</option>
                <option value="5">五月</option>
                <option value="6">六月</option>
                <option value="7">七月</option>
                <option value="8">八月</option>
                <option value="9">九月</option>
                <option value="10">十月</option>
                <option value="11">十一月</option>
                <option value="12">十二月</option>
              </select>
              <select class="day">
                <% for (int i = 1; i < 32; i++) {%>
                <option value="<%=i%>"><%=i%></option>
                <%}%>
              </select>
              <select class="year">
                <option value="0">每年</option>
                <% for (int i = 1950; i < 2021; i++) {%>
                <option value="<%=i%>"><%=i%></option>
                <%}%>
              </select>
            </div>
            <p class="submit">
              <a class="button blue small" href="#"><i class="fa fa-check"></i> 修改</a>
              <a class="button grey small" href="#"><i class="fa fa-times"></i> 取消</a>
            </p>
           </div>
         </div>
      </div>
    </div>
  </div>

  <div class="movebox" id="updateTask">
    <div class='arrow'></div><div class='arrow-border'></div>
    <form class="task">
      <h3>修改任务</h3>
      <p class="task_body">
        <input id="update_taskId" type="hidden" value="" />
        <input class="autofocus" id="update_taskTitle" size="25" type="text" />
      </p>
      <div>
        <h5>到期时间</h5>
        <p>
          <div class="datetimepicker_container"><input class="autofocus dueDate" id="update_dueDate" size="25" type="text" /></div>
        </p>
        <h5>任务负责人</h5>
        <p>
          <select id="update_responsibleUserId" class="responsibleUserId"></select></p>
        <h5>任务分类</h5>
        <p>
          <select id="update_categoryId" class="categoryId"></select>
          <% if (user.isAdmin) {%>
          <a href="<%=request.getContextPath()%>/taskcategory" class="edit_categories">编辑分类</a>
          <% }%>
        </p>
        <p>
          <input class="checkbox" id="update_taskVisible" type="checkbox" value="1" />
          <label for="update_taskVisible">所有人可以看见这个任务</label>
        </p>
      </div>
      <div class="submit">
        <a id="update_task_button" class="button blue small closePopbox" href="#"><i class="fa fa-check"></i> 修改任务</a>
        &nbsp;&nbsp;<a href="#" class="closePopbox" id="update_task_cancel_link">取消</a>
      </div>
    </form>
  </div>

  <div id="callphone-popup" class="white-popup mfp-hide">
    <div class="popup-title"><span class="title">拨打电话</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="popup-content">
      <div class="callphonelist" id="callphonelist">
        <h3><%=Util.HTMLEncode(customerInfo.name)%></h3>
        <%
        int phoneNum = 0;
        for (String p:phones) {%>
        <div class='item phonecall'><span class='telephone'><%=Util.HTMLEncode(p)%></span> <a id='callphone_link_<%=customerInfo.id%>_<%=phoneNum%>' class='noiconbutton green small' href='#'>打电话</a></div>
        <%
        phoneNum++;
        }%>
        <script>
          $("div.phonecall a").click(function(e) {
            e.preventDefault();
            if (!isDialing) {
              phoneCall($(this).parent().find("span").text(), $(this).attr("id"));
            } else {
              //phone.hangup();
              phoneHangUp();
            }
          });
        </script>
        <%for (Map<String, Object> people : peoples) {%>
        <div class='phonecontainer' id='phoneContainer_<%=people.get("CustomerId")%>'>
          <h3><%=Util.HTMLEncode((String)people.get("Name"))%></h3>
        </div>
        <%}%>
      </div>
    </div>
  </div>

  <div id="emailEditor-popup" class="white-popup big mfp-hide">
    <div class="popup-title"><span class="title">发送邮件</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="popup-content">
      <div id="emailEditor" class="mailEditoer">
      <form action="" autocomplete="off" method="post" id="mailForm">
        <div class="form-group">
          <label for="to">收件人:</label>
          <input type="text" title="多个邮箱之间用分号分割，比如user1@test.com; user2@test.com" id="email_to" tabindex="1">
        </div>
        <div class="form-group">
          <label for="subject">主题:</label>
          <input type="text" id="email_subject" tabindex="2">
        </div>
        <div class="file-group">
          <input type="file" id="email_file_upload" name="email_file_upload" />
        </div>
        <div class="message-editor">
          <textarea placeholder="邮件正文 ..." style="height:320px;width:650px;" id="email_message" name="email_message"></textarea>
        </div>
      </form>
      </div>
    </div>
    <div class="buttonbar">
      <div class="right">
        <a style="padding-right:20px;" href="<%=request.getContextPath()%>/users/<%=user.userId%>/edit" target="_blank">设置SMTP信息</a>
        <a id="sendEmail-link" class="button blue small" href="#"><i class="fa fa-check"></i> 发送</a>
        <a class="button grey small popup-close-button" href="#"><i class="fa fa-times"></i> 取消</a>
      </div>
      <div class="message" id="email_tips_message"></div>
    </div>
  </div>

  <script type="text/javascript" src="<%=request.getContextPath()%>/script/wysihtml5-0.3.0.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-wysihtml5.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-wysihtml5.zh-CN.js"></script>

  <div id="delete-popup" v="0" class="white-popup mfp-hide">
    <div class="popup-title"><span class="title">您确信要删除这些客户信息吗？</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="popup-content">
      客户被删除后，所有相关备注，任务和文件都将被删除。并且不可恢复。
    </div>
    <div class="buttonbar">
      <div class="right">
        <a id="detail-delete-link" class="button blue small" href="#"><i class="fa fa-check"></i> 确定</a>
        <a class="button grey small popup-close-button" href="#"><i class="fa fa-times"></i> 取消</a>
      </div>
      <div class="message"></div>
    </div>
  </div>

  <div id="callrecord-popup" class="white-popup mfp-hide">
    <div class="popup-title"><span class="title">通话录音</span> <span class="popup-close-button"><i class="fa fa-times"></i>&nbsp;</span></div>
    <div class="popup-content">
      <div id="jquery_jplayer_1" class="jp-jplayer"></div>
      <div id="jp_container_1" class="jp-audio" role="application" aria-label="media player">
      	<div class="jp-type-single">
      		<div class="jp-gui jp-interface">
      			<div class="jp-controls">
      				<button class="jp-play" role="button" tabindex="0">play</button>
      				<button class="jp-stop" role="button" tabindex="0">stop</button>
      			</div>
      			<div class="jp-progress">
      				<div class="jp-seek-bar">
      					<div class="jp-play-bar"></div>
      				</div>
      			</div>
      			<div class="jp-volume-controls">
      				<button class="jp-mute" role="button" tabindex="0">mute</button>
      				<button class="jp-volume-max" role="button" tabindex="0">max volume</button>
      				<div class="jp-volume-bar">
      					<div class="jp-volume-bar-value"></div>
      				</div>
      			</div>
      			<div class="jp-time-holder">
      				<div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
      				<div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
      				<div class="jp-toggles">
      					<button class="jp-repeat" role="button" tabindex="0">repeat</button>
      				</div>
      			</div>
      		</div>
      		<div class="jp-details">
      			<div class="jp-title" aria-label="title">&nbsp;</div>
      		</div>
      		<div class="jp-no-solution">
      			<span>您需要升级您的浏览器</span>
      			您的浏览器不支持录音播放，需要升级Flash组件 <a href="http://get.adobe.com/flashplayer/" target="_blank">升级Flash组件</a>.
      		</div>
      	</div>
      </div>
    </div>
  </div>
  <input type="hidden" id="referenceUrl" value="/company/<%=customerInfo.id%>">
  <input type="hidden" id="referenceTitle" value="<%=Util.HTMLEncode(customerInfo.name)%>">
  <input type="hidden" id="referenceId" value="<%=customerInfo.id%>">
  <input type="hidden" id="referenceType" value="<%=Const.TYPE_COMPANY%>">
</body>
</html>